package com.zx.web.service.impl;

import com.zx.bean.Goods;
import com.zx.bean.GoodsType;
import com.zx.web.dao.AdminGoodsDao;
import com.zx.web.dao.AdminGoodsTypeDao;
import com.zx.web.dao.impl.AdminGoodsDaoImpl;
import com.zx.web.dao.impl.AdminGoodsTypeDaoImpl;
import com.zx.web.service.AdminGoodsService;

import java.util.List;

/**
 * @author 章鑫
 * @version V1.0
 * @Project 2022-09-05
 * @Package com.zx.web.service.impl
 * @Description:
 * @Date 2022/9/16 15:43
 */
public class AdminGoodsServiceImpl implements AdminGoodsService {

    AdminGoodsDao adminGoodsDao = new AdminGoodsDaoImpl();
    AdminGoodsTypeDao adminGoodsTypeDao = new AdminGoodsTypeDaoImpl();

    @Override
    public List<Goods> getGoodsList() {
        List<Goods> goodsList = adminGoodsDao.getGoodsList();

        for (Goods goods : goodsList) {
            GoodsType goodsType = adminGoodsTypeDao.findGoodTypeParent(goods.getTypeid());
            goods.setTypeName(goodsType.getName());
        }
        return goodsList;
    }

    @Override
    public void addGoods(Goods goods) {
        adminGoodsDao.addGoods(goods);
    }
}
